﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using FluorineFx;

namespace Game.Server.Socket
{
    /// <summary>
    /// Socket数据包
    /// </summary>
    public class SocketPack
    {
        private ASObject _packData = new ASObject();

        /// <summary>
        /// Socket数据包
        /// </summary>
        /// <param name="rootPackCode">数据包根编号</param>
        /// <param name="packCode">数据包子编号</param>
        /// 
        public SocketPack(int rootPackCode, int packCode, int dataTransferType)
        {
            AddDataItem("dataTransferType", dataTransferType);
            AddDataItem("rootPackCode", rootPackCode);
            AddDataItem("packCode", packCode);
        }

        /// <summary>
        /// 数据包根编号
        /// </summary>
        public int DataTransferType
        {
            get
            {
                return (int)_packData["dataTransferType"];
            }
        }

        /// <summary>
        /// 数据包根编号
        /// </summary>
        public int RootPackCode
        {
            get
            {
                return (int)_packData["rootPackCode"];
            }
        }

        /// <summary>
        /// 数据包子编号
        /// </summary>
        public int PackCode
        {
            get
            {
                return (int)_packData["packCode"];
            }
        }

        /// <summary>
        /// 数据包
        /// </summary>
        public ASObject PackData
        {
            get
            {
                return _packData;
            }
            set
            {
                _packData = value;
            }
        }

        /// <summary>
        /// 增加数据项
        /// </summary>
        /// <param name="key">项key</param>
        /// <param name="value">项值</param>
        public void AddDataItem(string key, object value)
        {
            _packData.Add(key, value);
        }
    }
}
